package com.jh.fcsm.controller;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 自定义404处理页面
 */
@RestController
public class CustomErrorController implements ErrorPageRegistrar {
    @Override
    public void registerErrorPages(ErrorPageRegistry registry) {
        //400对应处理接口
        ErrorPage page400 = new ErrorPage(HttpStatus.BAD_REQUEST, "/404.html");
        //404对应处理接口
        ErrorPage page404 = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
        registry.addErrorPages(page400,page404);
    }
    @GetMapping("/404.html")
    public String error404(){
        return "404";
    }

}
